import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
import p001 from './p001';
import p003 from './p003';
import p004 from './p004';
import p005 from './p005';

export default async function a012(fd: IFeidaoAiBrowserComponent) {
	// todo
	const res = await nodejs<{dt: Array<{}>;dt1: number}>('question-bank/zj-000001/s001',{pn:1});
	if (res.dt1 <= 20) {
		render(fd,res.dt,p001,"p001",'inner');
	} else {
		render(fd,res.dt,p001,"p001",'inner');
		render(fd,res.dt1,p003,"p003",'inner');
	}
	const res1 = await nodejs<{dt: Array<{question_bank_type: string}>,dt1: Array<{topic_type: string}>}>('question-bank/zj-000001/s002',{});
	const ret=new Array();
	for (let c=0;c < res1.dt.length;c++) {
	 ret[c] = res1.dt[c].question_bank_type;
	}
	// 数组去重
	 const a = new Set(ret);
	 const newArr = Array.from(a); // Array.from方法可以将 Set 结构转为数组。
	 const a1=new Array();
	 for (let i=0;i < res1.dt1.length;i++) {
		 a1[i] = res1.dt1[i].topic_type;
	 }
	 const set1 = new Set(a1);
	 const topic_type = Array.from(set1);
	render(fd,newArr,p004,"p004",'inner');
	render(fd,topic_type,p005,"p005",'inner');
}
